# Maintainer: Taner Tas <taner76@gmail.com>
pkgname=advancemame
pkgver=3.9
pkgrel=0
pkgdesc="A port of the MAME emulator for Arcade Monitors and TVs but also for LCDs and PC monitors"
url="http://www.advancemame.it"
arch="all"
license="GPL-2.0-only"
makedepends="
	alsa-lib-dev
	clang-dev
	expat-dev
	freetype-dev
	linux-headers
	sdl2-dev
	slang-dev
	zlib-dev
	"
subpackages="$pkgname-doc $pkgname-data::noarch $pkgname-mess $pkgname-menu"
source="https://github.com/amadvance/${pkgname}/releases/download/v${pkgver}/${pkgname}-${pkgver}.tar.gz
	fix-ppc64le-float128.patch"
options="!check"

prepare() {
	default_prepare
}

build() {
	cd "$builddir"

case "$CARCH" in
	armhf|mips*)
		true
	;;
	*)
		export CC=clang
		export CXX=clang++
	;;
esac


	./configure \
		--build=$CBUILD \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-fb \
		--enable-sdl2
	make
}

package() {
	cd "$builddir"
	make bindir="${pkgdir}/usr/bin/" \
	datadir="${pkgdir}/usr/share/" \
	mandir="${pkgdir}/usr/share/man/" \
	pkgdocdir="${pkgdir}/usr/share/doc/${pkgname}/" \
	install
}

data() {
	pkgdesc="Distrubition files for advancemame"
	depends="$pkgname"
	mkdir -p "$subpkgdir"/usr/share/advance
	mv "$pkgdir"/usr/share/advance/* "$subpkgdir"/usr/share/advance/
}

mess() {
	pkgdesc="Advancemame port of MESS."
	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/advmess "$subpkgdir"/usr/bin/

}

menu() {
	pkgdesc="An emulator frontend with sound and animated previews of your games."
	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/advmenu "$subpkgdir"/usr/bin/

}
sha512sums="43f9ba746f222b17ade2d213d6af7cc8fe6b3ee6008633f02b8877f4c7f75628bdf1cc9718db09f5f9a482d194c8ba94f9047334e8012d23c598454e5dab2eb3  advancemame-3.9.tar.gz
d42a9b3c65c2d96be5287c7541eb1e911562b3f2aaf07c55c1849725592857716ce496405e3da2243edcbd4b7307226306533ddf66ef2e081b4c492412930d1b  fix-ppc64le-float128.patch"
